/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2018-11-06     SummerGift   first version
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
//#include "dfs_fs.h"
//#include "drv_spi.h"
//#include "spi_flash_sfud.h"

/* defined the LED4 pin: PC2 */
#define LED4_PIN    GET_PIN(C, 2)
#define LED5_PIN    GET_PIN(C, 3)

//const struct dfs_mount_tbl mount_table[] =
//{
//    {"flash0", "/", "elm", 0, 0},
//    {0}
//};

//static int rt_hw_spi_flash_init(void)
//{
//    __HAL_RCC_GPIOA_CLK_ENABLE();
//    rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);

//    if (RT_NULL == rt_sfud_flash_probe("W25Q64", "spi10"))  
//    {
//        return -RT_ERROR;
//    };

//    return RT_EOK;
//}

//INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);


int main(void)
{
    int count = 1;
    /* set LED0 pin mode to output */
    rt_pin_mode(LED4_PIN, PIN_MODE_OUTPUT);
	rt_pin_mode(LED5_PIN, PIN_MODE_OUTPUT);
	
//	__HAL_RCC_GPIOA_CLK_ENABLE();
//    rt_hw_spi_device_attach("spi1", "spi10", GPIOA, GPIO_PIN_4);
//	
//    MFRC522(MFRC522_SS_PIN, MFRC522_RST_PIN);
//    PCD_Init();		// Init MFRC522
//    rt_thread_mdelay(4);
//    PCD_DumpVersionToSerial();
//    rt_kprintf("Scan PICC to see UID, SAK, type, and data blocks...\n");

//    uid = get_uid();

    while (count++)
    {
        rt_pin_write(LED4_PIN, PIN_HIGH);
		rt_pin_write(LED5_PIN, PIN_LOW);
        rt_thread_mdelay(500);
        rt_pin_write(LED4_PIN, PIN_LOW);
		rt_pin_write(LED5_PIN, PIN_HIGH);
        rt_thread_mdelay(500);

//        // Reset the loop if no new card present on the sensor/reader. This saves the entire process when idle. And if present, select one.
//		if ( ! PICC_IsNewCardPresent() || ! PICC_ReadCardSerial())
//		{
//			rt_thread_mdelay(50);
//			continue;
//		}

//        // Dump debug info about the card; PICC_HaltA() is automatically called
//	    PICC_DumpToSerial(uid);
//        break;
    }

//    PCD_End();

    return RT_EOK;
}


